package com.huowenjie.controller;

import com.github.pagehelper.PageInfo;
import com.huowenjie.api.TestApi;
import com.huowenjie.entity.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;


@RestController
@CrossOrigin
public class UserControoler {

    @Autowired
    TestApi testApi;

    @RequestMapping("userList")
    public PageInfo<User> userList(Integer pageNum){
        System.out.println(pageNum);
        PageInfo<User> userPageInfo = testApi.userList(pageNum);
        return userPageInfo;
    };


    @RequestMapping("register")
    public String register(User user){
        testApi.register(user);
        return "success";
    }

    @RequestMapping("login")
    public String login(User user){
        String login = testApi.login(user);
        return login;
    }

}
